package com.android.svmc.app.mobile.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

public class SettingUtils implements CommonDefine{
	/**
	 *  Save value to preferences on modul setting.
	 * @param type
	 * @param value
	 */
	public static  void savebooleanPreferences (Context context,String type,boolean value){
		SharedPreferences data = PreferenceManager.getDefaultSharedPreferences(context);
		SharedPreferences.Editor editor = data.edit();
		editor.putBoolean(type, value);
		editor.commit();
	}
	
	public static boolean getbooleanPreferences (Context context,String type){
		SharedPreferences data = PreferenceManager.getDefaultSharedPreferences(context);
		return data.getBoolean(type, false);
		
	}
	
	public static void saveStringPreferences (Context context,String type,String value){
		SharedPreferences data = PreferenceManager.getDefaultSharedPreferences(context);
		SharedPreferences.Editor editor = data.edit();
		editor.putString(type, value);
		editor.commit();
	}
	
	public static String getStringPreferences (Context context,String type){
		SharedPreferences data = PreferenceManager.getDefaultSharedPreferences(context);
		return data.getString(type, "");
	}
    public static void hideSoftKeyboard(View v) {
    InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); 
    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}

}
